import tkinter as tk
import tkinter.font as tkFont
import tkinter.messagebox as tkMsgBox

fpx = 10
fpy = 10

"""单行文本"""
top = tk.Tk()
top.resizable(False, False)

defaultFont = tkFont.Font(top, size = 20)

userStr = tk.StringVar()
pwdStr = tk.StringVar()

def OnOK():

    if userStr.get() == '':
        tkMsgBox.showerror('*_*', 'Who are you?')
    elif pwdStr.get() == '':
        tkMsgBox.showinfo('^_^', "What's the magic word?")
    else:
        resultTop = tk.Tk()
        resultFont = tkFont.Font(resultTop, size = 20)

        userInfoFrame = tk.Frame(resultTop)
        userInfoFrame.pack(side=tk.TOP, fill=tk.X, padx=fpx, pady=fpy)
        userInfo1 = tk.Label(userInfoFrame, text='用户名: ', anchor=tk.W, width=8, font=resultFont)
        userInfo1.pack(side=tk.LEFT)
        userInfo2 = tk.Label(userInfoFrame, text=userStr.get(), anchor=tk.E, width=8, font=resultFont)
        userInfo2.pack(side=tk.RIGHT)

        pwdInfoFrame = tk.Frame(resultTop)
        pwdInfoFrame.pack(side=tk.TOP, fill=tk.X, padx=fpx, pady=fpy)
        pwdInfo1 = tk.Label(pwdInfoFrame, text='密码: ', width=8, anchor=tk.W, font=resultFont)
        pwdInfo1.pack(side=tk.LEFT)
        pwdInfo2 = tk.Label(pwdInfoFrame, text=pwdStr.get(), width=8, anchor=tk.E, font=resultFont)
        pwdInfo2.pack(side=tk.RIGHT)

userFrame= tk.Frame(top)
userFrame.pack(side = tk.TOP, fill=tk.X, padx = fpx, pady=fpy)
userLabel = tk.Label(userFrame, text='用户名:', width=8, anchor=tk.E, font=defaultFont)
userLabel.pack(side=tk.LEFT)


userEntry = tk.Entry(userFrame, width=20, font=defaultFont, textvariable=userStr)
userEntry.pack(side=tk.LEFT)

pwdFrame= tk.Frame(top)
pwdFrame.pack(side=tk.TOP, fill=tk.X, padx = fpx, pady=fpy)
pwdLabel = tk.Label(pwdFrame, text='密码:', width=8, anchor=tk.E, font=defaultFont)
pwdLabel.pack(side=tk.LEFT)


pwdEntry = tk.Entry(pwdFrame, width=20, font=defaultFont, textvariable=pwdStr, show='*')
pwdEntry.pack(side=tk.LEFT)

btnFrame = tk.Frame(top)
btnFrame.pack(side=tk.TOP, fill=tk.X, padx=fpx, pady=fpy)

confirmBtn = tk.Button(btnFrame, width=8, text='确认', font=defaultFont, command=OnOK)
confirmBtn.pack(side=tk.TOP)

top.mainloop()